<?php

require __DIR__ . '/../../vendor/autoload.php';

use Parse\CombinatorParser;
use Parse\StringParser;

{
    $parser = new CombinatorParser(
        array(
            new StringParser("Hello"),
            new StringParser(" "),
            new StringParser("World!")
        )
    );

    try {
        var_dump($parser->parse("Hello World!")
                 === array("Hello", " ", "World!"));
    } catch (ParseException $e) {
        var_dump(false);
    }

    $parser = new CombinatorParser(
        array(
            new StringParser("Hello"),
            new StringParser(" "),
            new StringParser("World!")
        ),
        function ($hello, $space, $world) {
            return $hello;
        }
    );

    try {
        var_dump($parser->parse("Hello World!") === "Hello");
    } catch (ParseException $e) {
        var_dump(false);
    }
}
